﻿@using SignalRSample.Models
@model List<UserVm>
@{

    ViewData["Title"] = "About";
}
<h2>@ViewData["Title"]</h2>
<h3>@ViewData["Message"]</h3>

<p>Use this area to provide additional information.</p>



<table class="table table-bordered table-striped table-hover table-condensed">
    <thead>
        <tr>
            <th>id</th>
            <th>name</th>
            <th>age</th>
            <th>operation</th>
        </tr>
    </thead>
    <tbody>
        @if (Model != null && Model.Any())
        {
            @foreach (var item in Model)
            {
                <tr>
                    <th>@item.Id</th>
                    <th>@item.Name</th>
                    <th>@item.Age</th>
                    <th><button class="btn btn-danger btn—remove">Remove</button></th>
                </tr>
            }
        }
        else
        {
            <p>没有查询到任何用户！</p>
        }
    </tbody>
</table>
@section scripts{
    <script type="text/javascript">
        $(function () {
            $('.btn—remove').on('click', function () {
                /*/Home/RemoveUserById?id=*/
                var $self = $(this);
                var $parent = $self.parent().parent();
                var $id = $parent.find('th').eq(0);
                var id = $id.text().trim();
                $.ajax({
                    url:'/Home/RemoveUserById',
                    type: 'Post',
                    data: { id: id },
                    success: function (data) {
                     
                    }
                });
                $parent.fadeOut();
            });
        });
    </script>
}